home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 27.zip / BS1 part 27 / ImageMaster_d3.adf / piarc.lzh.parta / BMRD.rexx < prev    next >
OS/2 REXX Batch file  |  1993-03-23  |  5KB  |  136 lines

  1. /*
  2.  * BMRD.rexx
  3.  *
  4.  *  Written by: Pete Patterson & Ben Williams
  5.  * Last Update: February 27th, 1993
  6.  *         For: Black Belt Systems Amiga image processing software "IM"
  7.  * --------------------------------------------------------------------
  8.  *    Revision: 2.00
  9.  */
  10.  
  11. parse arg fullname
  12. call pragma('stack',20000);
  13.  
  14. if ~show('L',"rexxsupport.library") then do
  15.   if ~addlib('rexxsupport.library',0,-30,0) then do
  16.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  17.     say 'Cannot operate PI Modules without this library - sorry!';
  18.     'finish';
  19.     exit 10;
  20.     end;
  21.   end;
  22.  
  23. prtnme = 'IP_Port'; /* assume Image Professional */
  24. if show('P','IP_Port') = 0 then do
  25.   if show('P','IM_Port') = 0 then do
  26.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  27.     say "This script requires IP, IM or IM F/c to run!";
  28.     exit(20);
  29.     end;
  30.   else do
  31.     prtnme = 'IM_Port';
  32.     end;
  33.   end;
  34.  
  35. cmdpath = 'c:';
  36. if open(fhandle,'rexx:picmdpath','read') then
  37.   do
  38.     cmdpath = readln(fhandle);
  39.     call close(fhandle);
  40.   end
  41.  
  42. if fullname = "" then
  43.   do
  44.     options results;
  45.     address command 'rx rxpi:GetFile.rexx';
  46.     if open(fhandle,'ram:IP_FNAME.tmp','read') then
  47.       do
  48.         fullname = readln(fhandle);
  49.         call close(fhandle);
  50.       end
  51.   end
  52.  
  53. thispath = gimmepath(fullname);
  54.  
  55. /* --------------------------------------------------------------------- */
  56. /* ------------- BEGINNING of format-specific ARexx code --------------- */
  57. /* --------------------------------------------------------------------- */
  58.  
  59. address command cmdpath||'BMRD c "'||fullname||'"';
  60. if rc ~= 0 then do; address(prtnme); 'message "Cannot read '||fullname||' Error = '||rc||'"'; 'finish'; exit 0; end;
  61. call open(fhandle,'ram:IP_BMRD.tmp','read'); rstring = readln(fhandle); call close(fhandle);
  62. parse var rstring width '/' height '/' depth
  63. address command 'c:delete >nil: ram:IP_BMRD.tmp';
  64. if height < 0     then do; 'message "Bad Height:' height '"'; 'finish'; exit 0; end;
  65. if height > 32767 then do; 'message "Bad Height:' height '"'; 'finish'; exit 0; end;
  66. if width  < 0     then do; 'message "Bad Width:'  width  '"'; 'finish'; exit 0; end;
  67. if width  > 32767 then do; 'message "Bad Width:'  width  '"'; 'finish'; exit 0; end;
  68. if depth  < 2     then do; 'message "Bad Depth:'  depth  '"'; 'finish'; exit 0; end;
  69. if depth  > 4     then do; 'message "Bad Depth:'  depth  '"'; 'finish'; exit 0; end;
  70.  
  71. if depth = 2 then do
  72.   options results; 'gadgets "Pads","Only","Silk","Layer","Layer","One","Layer","Two"'; pxsz = result-1; options;
  73.   if pxsz < 0 then do; 'finish'; exit 0; end;
  74.   end
  75. else do
  76.   options results; 'gadgets "Pads","Only","Silk","Layer","Layer","One","Layer","Two","Layer","Three","Layer","Four"'; pxsz = result-1; options;
  77.   if pxsz < 0 then do; 'finish'; exit 0; end;
  78.   end
  79.  
  80. address(prtnme);
  81. 'imtofront';
  82. 'autoredraw 0';
  83. options results;
  84. 'newtargetted '||width||' '||height||' "'||gxname||'"'
  85. if rc ~= 0 then do; 'options'; "message Can't allocate buffer!"; 'autoredraw 1'; 'finish'; exit 0; end;
  86. bnum = result;
  87. 'backin '||bnum;
  88. plugadr = result;
  89. options;
  90. 'lockimage '||bnum;
  91. address command cmdpath||'BMRD d'||plugadr||' "'||fullname||'" '||pxsz;
  92. 'unlockimage '||bnum;
  93. 'imtofront';
  94. 'autoredraw 1';
  95. 'finish';
  96. exit 0;
  97.  
  98. /* --------------------------------------------------------------------- */
  99. /* ---------------- END of format-specific ARexx code ------------------ */
  100. /* --------------------------------------------------------------------- */
  101.  
  102. gimmepath:
  103.   arg fullnamegx;
  104.     tempgx = reverse(fullnamegx);
  105.     lengx = length(fullnamegx);   /* get length of string */
  106.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  107.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  108.     seploc = 0; /* assumes current dir, no path supplied */
  109.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  110.       seploc = (lengx - slashdex)+1;
  111.       end;
  112.     else do
  113.       if colondex ~= 0 then do /* we assume we are on a device */
  114.         seploc = (lengx - colondex)+1;
  115.         end;
  116.       end;
  117.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  118.   gxpath = left(fullnamegx,seploc);
  119.   return(gxpath);
  120.  
  121. expandfilename:
  122.   parse arg jfile;
  123.   if index(jfile,':') = 0 then do
  124.     curdir = pragma(D);
  125.     if right(curdir,1) ~= ':' then do
  126.       if right(curdir,1) ~= '/' then do
  127.         if curdir ~= '' then do
  128.           curdir = curdir || '/';
  129.           end;
  130.         end;
  131.       end;
  132.     jfile = curdir||jfile;
  133.     end;
  134.   return(jfile);
  135.  
  136.